package DBClasses;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.UNSPECIFIED)
public class User
{
	@PrimaryKey	
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	public Long getId()
	{
		return id;
	}

	@Unique
	@Persistent
	private String login;

	public String getLogin()
	{
		return login;
	}

	@Persistent
	private String password;

	public String getPassword()
	{
		return password;
	}

	@Persistent
	private Boolean is_news_admin;
	@Persistent
	private String _name;

	public void setName(String name)
	{
		_name = name;
	}

	public String getName()

	{
		return _name;
	}

	@Persistent
	private String _sname;

	public void setSName(String sname)
	{
		_sname = sname;
	}

	public String getSName()
	{
		return _sname;
	}

	@Persistent
	private String _ptrn;

	public void setPtrn(String ptrn)
	{
		_ptrn = ptrn;
	}

	public String getPtrn()
	{
		return _ptrn;
	}

	@Persistent
	@Unique
	private String _mail;

	public void setMail(String mail)
	{
		_mail = mail;
	}

	public String getMail()
	{
		return _mail;
	}

	@Persistent
	private boolean _sex; // true - male

	public void setSex(boolean sex)
	{
		_sex = sex;
	}

	public boolean getSex()
	{
		return _sex;
	}

	public Boolean haveNewsAccess()
	{
		return is_news_admin;
	}

	public void setNewsAccess(Boolean value)
	{
		is_news_admin = value;
	}

	@Persistent
	private Boolean is_shop_admin;

	public Boolean haveShopAccess()
	{
		return is_shop_admin;
	}

	public void setShopAccess(Boolean value)
	{
		is_shop_admin = value;
	}

	@Persistent
	private Boolean is_super_admin;

	public Boolean haveSuperAccess()
	{
		return is_super_admin;
	}

	public User(String login, String password)
	{
		this.login = login;
		this.password = password;
		is_news_admin = false;
		is_shop_admin = false;
		is_super_admin = false;
	}

	public User(String login, String password, String name, String sname,
			String mail, boolean sex)
	{
		this.login = login;
		this.password = password;
		this._name = name;
		this._sname = sname;
		this._mail = mail;
		this._sex = sex;
		is_news_admin = false;
		is_shop_admin = false;
		is_super_admin = false;
	}
}
